var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/help/UserHelp/UserCompanyHelp.tsx
var UserCompanyHelp_exports = {};
__export(UserCompanyHelp_exports, {
  default: () => UserCompanyHelp_default
});
module.exports = __toCommonJS(UserCompanyHelp_exports);
var import_antd = require("antd");
var import_react = require("react");
var import_util = require("../../../util");
var import_org_tree = require("../../org-tree");
function OrgTree(props) {
  const params = (0, import_react.useMemo)(() => {
    return { containDept: false, dataAccessAuth: true, ...props.params };
  }, [props.params]);
  return /* @__PURE__ */ React.createElement(import_org_tree.OrgTree, { defaultSelectedFirstNode: true, ...props, params });
}
function UserCompanyHelp(props) {
  const { multiple, borderStyle, treeProps, renderTable, getTable } = props;
  const [treeSelectedKeys, setTreeSelectedKeys] = (0, import_react.useState)([]);
  const onControlledSelect = (0, import_util.useRefCallback)((keys, { selectedNodes }) => {
    const treeNodes = selectedNodes.filter((xt) => !treeSelectedKeys.includes(xt.key)) || [];
    const treeKeys = keys.filter((xt) => !treeSelectedKeys.includes(xt)) || [];
    getTable().setExtraParam({ treeNodes });
    setTreeSelectedKeys(treeKeys);
  });
  const onChangeIfNeedSub = (0, import_util.useRefCallback)((value) => {
    getTable().setExtraParam({
      containLowOrgUser: value
    });
  });
  const handleFilter = (DefaultCom) => {
    return /* @__PURE__ */ React.createElement(React.Fragment, null, DefaultCom, /* @__PURE__ */ React.createElement(
      import_antd.Checkbox,
      {
        style: { marginBottom: 5 },
        onChange: (e) => {
          onChangeIfNeedSub(e.target.checked);
        }
      },
      "包含下级"
    ));
  };
  return /* @__PURE__ */ React.createElement(import_util.Layout.Flex, { direction: "row", style: { height: "100%" } }, /* @__PURE__ */ React.createElement("div", { style: { width: 200, borderLeft: borderStyle, borderBottom: multiple ? 0 : borderStyle } }, /* @__PURE__ */ React.createElement(
    OrgTree,
    {
      ...treeProps,
      showFilter: handleFilter,
      selectedKeys: treeSelectedKeys,
      onSelect: onControlledSelect,
      titleRender: ({ title, key }) => /* @__PURE__ */ React.createElement(
        import_antd.Dropdown,
        {
          disabled: !treeSelectedKeys.includes(key),
          trigger: ["contextMenu"],
          menu: { items: [{ key: "cancle", label: "取消选中" }] },
          placement: "top"
        },
        /* @__PURE__ */ React.createElement("span", null, title)
      ),
      convertNode: (node, levelIndex) => {
        if (levelIndex.level === 0 && levelIndex.index === 0) {
          onControlledSelect([node.key], { selectedNodes: [node] });
        }
        return node;
      }
    }
  )), /* @__PURE__ */ React.createElement(import_util.Layout.Flex, { style: { paddingBottom: multiple ? 32 : 0 } }, renderTable(1)));
}
var UserCompanyHelp_default = (0, import_react.memo)(UserCompanyHelp);
